package org.my;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class MyService {
    static {
        System.out.println("MyService init");
    }

    @Resource
    private JdbcTemplate jdbcTemplate;

    @Transactional
    //(rollbackFor = Exception.class)
    public void hello(Object vo) {
        doHello(vo, null);
    }

    @Transactional
    //(rollbackFor = Exception.class)
    private void doHello(Object vo, Object option) {
        System.out.println("Hello3 " + vo);

        // List<Map<String, Object>> maps = jdbcTemplate.queryForList("SELECT * FROM  users", new Object[]{});

        // jdbcTemplate.execute("INSERT INTO users (ID,name, age) VALUES (13,'Tom',
        // 25)");
        System.out.println(1);
        throw new RuntimeException("test");
    }

    public void hi(Object vo) {
        // rpc
        // sql查询
        doHi(vo);
    }

    @Transactional
    private void doHi(Object vo) {

    }
}
